﻿@model CategoryModel
@using Nop.Core
@using Nop.Core.Domain.Common;
@using Nop.Core.Domain.Seo;
@using Nop.Core.Infrastructure;
@using Nop.Web.Models.Catalog;
@using Nop.Web.Extensions;
@using Nop.Services.Localization
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    Html.AddMetaDescriptionParts(Model.MetaDescription);
    Html.AddMetaKeywordParts(Model.MetaKeywords);

    var canonicalUrlsEnabled = EngineContext.Current.Resolve<SeoSettings>().CanonicalUrlsEnabled;
    if (canonicalUrlsEnabled)
    {
        var categoryUrl = Url.RouteUrl("Category", new { SeName = Model.SeName }, this.Request.Url.Scheme);
        Html.AddCanonicalUrlParts(categoryUrl);
    }

    var breadcrumbDelimiter = EngineContext.Current.Resolve<CommonSettings>().BreadcrumbDelimiter;

    var seoSettings = EngineContext.Current.Resolve<SeoSettings>();
    //open graph META tags
    if (seoSettings.OpenGraphMetaTags)
    {
        var storeName = EngineContext.Current.Resolve<IStoreContext>().CurrentStore.GetLocalized(x => x.Name);
        Html.AddHeadCustomParts("<meta property=\"og:type\" content=\"category\" />");
        Html.AddHeadCustomParts("<meta property=\"og:title\" content=\"" + Html.Encode(Model.Name) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:description\" content=\"" + Html.Encode(Model.MetaDescription) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:image\" content=\"" + Model.PictureModel.ImageUrl + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:url\" content=\"" + Request.Url.AbsoluteUri + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:site_name\" content=\"" + Html.Encode(storeName) + "\" />");
    }

    //Twitter META tags
    if (seoSettings.TwitterMetaTags)
    {
        var storeName = EngineContext.Current.Resolve<IStoreContext>().CurrentStore.GetLocalized(x => x.Name);
        Html.AddHeadCustomParts("<meta property=\"twitter:card\" content=\"summary\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:site\" content=\"" + Html.Encode(storeName) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:title\" content=\"" + Html.Encode(Model.Name) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:description\" content=\"" + Html.Encode(Model.MetaDescription) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:image\" content=\"" + Model.PictureModel.ImageUrl + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:url\" content=\"" + Request.Url.AbsoluteUri + "\" />");
    }
 }

@*category breadcrumb*@
@if (Model.DisplayCategoryBreadcrumb)
{<ol class="breadcrumb">
		<li>
			<a href="@Url.RouteUrl("HomePage")" title="@T("Categories.Breadcrumb.Top")">@T("Categories.Breadcrumb.Top")</a>
			<span class="delimiter">@breadcrumbDelimiter</span>
		</li>
		@foreach (var cat in Model.CategoryBreadcrumb)
		{
			var isLastCategory = cat.Id == Model.Id;
			<li>
				@if (isLastCategory)
					{
					<strong class="current-item">@cat.Name</strong>
					}
					else
					{
					<a href="@Url.RouteUrl("Category", new { SeName = cat.SeName })" title="@cat.Name">@cat.Name</a>
						<span class="delimiter">@breadcrumbDelimiter</span>
					}
			</li>
		}
		</ol>
		@Html.Widget("categorydetails_after_breadcrumb")
}
<div class="page category-page">
	<div class="panel panel-default form-panel">
		<div class="panel-heading">
			<h3>@Model.Name</h3>
		</div>
		<div class="panel-body">
			<div class="page-body">
				<div>
					<!-- AddThis Button BEGIN --><div class="addthis_toolbox addthis_default_style ">
						<a class="addthis_button_preferred_1"></a>
						<a class="addthis_button_preferred_2"></a>
						<a class="addthis_button_preferred_3"></a>
						<a class="addthis_button_preferred_4"></a>
						<a class="addthis_button_compact"></a>
						<a class="addthis_counter addthis_bubble_style"></a>
					</div>
					<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=nopsolutions"></script><!-- AddThis Button END -->
				</div>
				@Html.Widget("categorydetails_top")
				@*description*@
				@if (!String.IsNullOrWhiteSpace(Model.Description))
				{
					<div class="category-description">
						@Html.Raw(Model.Description)
					</div>
				}
				@Html.Widget("categorydetails_before_subcategories")
				@*subcategories*@
				@if (Model.SubCategories.Count > 0)
				{
					<div class="row">
						@foreach (var item in Model.SubCategories)
						{
							<div class="col-md-3 col-xs-6 text-center">
								<div class="offer offer-default sub-category-category">
									<span class="title">
										<a href="@Url.RouteUrl("Category", new { SeName = item.SeName })" title="@item.PictureModel.Title">
											@item.Name
										</a>
									</span>
									<div class="">
										<a href="@Url.RouteUrl("Category", new { SeName = item.SeName })" title="@item.PictureModel.Title">
											<img alt="@item.PictureModel.AlternateText" src="@item.PictureModel.ImageUrl"
												 title="@item.PictureModel.Title" />
										</a>
									</div>
								</div>
							</div>
						}
					</div>
					<hr />
				}
				@Html.Widget("categorydetails_before_featured_products")
				@*featured products*@
				@if (Model.FeaturedProducts.Count > 0)
				{
					<div class="product-grid featured-product-grid">
						<div class="title">
							<strong>@T("Products.FeaturedProducts")</strong>
						</div>
						<div>
							@foreach (var item in Model.FeaturedProducts)
							{
								<div class="item-box col-md-3 col-sm-6 col-xs-12">
									@Html.Partial("_ProductBox", item)
								</div>
							}
						</div>
					</div>

				}
				@Html.Widget("categorydetails_after_featured_products")
				<div class="row form-inline">
					<div class="col-md-4 text-center">
						@*view mode*@
						@if (Model.PagingFilteringContext.AllowProductViewModeChanging && Model.Products.Count > 0)
						{
							<div class="form-group">
								<label for="products-viewmode" class="control-label hidden-xs">@T("Catalog.ViewMode")</label>
								@Html.DropDownList("products-viewmode", Model.PagingFilteringContext.AvailableViewModes, new { @class = "form-control", onchange = "setLocation(this.value);" })
							</div>
						}
					</div>
					<div class="col-md-4 text-center">
						@*sorting*@
						@if (Model.PagingFilteringContext.AllowProductSorting && Model.Products.Count > 0)
						{
							<div class="form-group">
								<label for="products-orderby" class="control-label hidden-xs">@T("Catalog.OrderBy")</label>
								@Html.DropDownList("products-orderby", Model.PagingFilteringContext.AvailableSortOptions, new { @class = "form-control", onchange = "setLocation(this.value);" })
							</div>
						}
					</div>
					<div class="col-md-4 text-center">
						@*page size*@
						@if (Model.PagingFilteringContext.AllowCustomersToSelectPageSize && Model.Products.Count > 0)
						{
							<div class="form-group">
								<label for="products-pagesize" class="control-label hidden-xs">@T("Catalog.PageSize")</label>
								@Html.DropDownList("products-pagesize", Model.PagingFilteringContext.PageSizeOptions, new { @class = "form-control", onchange = "setLocation(this.value);" })
								<label class="control-label hidden-xs">@T("Catalog.PageSize.PerPage")</label>
							</div>
						}
					</div>
					@Html.Widget("categorydetails_before_filters", Model.Id)
				</div>
				@if (Model.PagingFilteringContext.PriceRangeFilter.Enabled || Model.PagingFilteringContext.SpecificationFilter.Enabled)
				{
					<div class="row">
						@*filtering*@
						@if (Model.PagingFilteringContext.PriceRangeFilter.Enabled)
						{
							<div class="col-md-6">
								@Html.Partial("_FilterPriceBox", Model.PagingFilteringContext.PriceRangeFilter, new ViewDataDictionary())
							</div>
						}
						@*filtering*@
						@if (Model.PagingFilteringContext.SpecificationFilter.Enabled)
						{
							<div class="col-md-6">
								@Html.Partial("_FilterSpecsBox", Model.PagingFilteringContext.SpecificationFilter, new ViewDataDictionary())
							</div>
						}

					</div>
				}
				@Html.Widget("categorydetails_before_product_list")
				@*product list*@
				@if (Model.Products.Count > 0)
				{
					if (Model.PagingFilteringContext.ViewMode == "list")
					{
						@*list mode*@
						<div class="product-list">
							@foreach (var product in Model.Products)
							{
								<div class="row">
									<div class="col-md-12">
										<div class="offer">
											@Html.Partial("_ProductBox", product)
										</div>
									</div>
								</div>
							}
						</div>
					}
					else
					{
						@*grid mode*@
						<div class="product-grid">
							<div class="row">
								@foreach (var product in Model.Products)
								{
									<div class="col-md-4">
										<div class="offer">
											@Html.Partial("_ProductBox", product)
										</div>
									</div>

								}
							</div>
						</div>
					}
				}
				<div class="pager">
					@Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber")
				</div>
				@Html.Widget("categorydetails_bottom")
			</div>
		</div>

	</div>
</div>
